package com;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.DBManipulation;

/**
 * Servlet implementation class PurchaseVoucherServlet
 */
public class PurchaseVoucherServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public PurchaseVoucherServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub

		try { 
			
				System.out.println("In Purchase voucher servlet");
				
				PurchaseUserBean user1 = new PurchaseUserBean(); 
			
				user1.setPurchaseOrderNumber(request.getParameter("purordnum"));
				user1.setPurchaseInvoiceNumber(request.getParameter("purInnum"));
				user1.setPurchaseDate(request.getParameter("purdte"));
				user1.setSupplierName(request.getParameter("supname"));
				user1.setSupplierCode(request.getParameter("supcode"));
				user1.setSupplierInvoiceNumber(request.getParameter("supinnum"));
				user1.setProductName(request.getParameter("purprodname"));
				user1.setPurchaseProdQuantity(Integer.parseInt(request.getParameter("purprodquantity")));
				user1.setPurchaseProdRate(Double.parseDouble(request.getParameter("purprodrate")));
				user1.setPurchaseNetAmount(Double.parseDouble(request.getParameter("purnetamount")));
				user1.setPurchaseTaxCategory(Double.parseDouble(request.getParameter("purtaxcat")));
				user1.setPurchaseTaxAmount(Double.parseDouble(request.getParameter("purtaxamount")));
				user1.setPurchaseTransport(Double.parseDouble(request.getParameter("purtransport")));
				user1.setPurchaseOtherCosts(Double.parseDouble(request.getParameter("purothercosts")));
				user1.setPurchaseTotalAmount(Double.parseDouble(request.getParameter("purtotalamount")));
				user1.setPurchaseCreditLimit(Integer.parseInt(request.getParameter("purcredlimit")));
			

				DBManipulation dbc= new DBManipulation();
				dbc.insertPurchaseVoucher(user1);
			
		}
		catch (Throwable theException) 
		{ 
			System.out.println(theException); 
			} 
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
